<%@ page language="java" isELIgnored="false" import="java.util.*"
	pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
 <%@page import="com.kit.authority.entity.User"%>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@include file="/common/include.jsp"%>
<link href="<%=request.getContextPath() %>/fare/js/datePicker/skin/WdatePicker.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<%=request.getContextPath() %>/fare/js/datePicker/WdatePicker.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户意见反馈</title>
<script>
		$(function(){
			$('#submitForm').hide();
			$('#opinionList').datagrid({
				//title: '列表',
				pagination:true,
				nowrap: false,
                striped: true,
                collapsible: true,
				toolbar:[{
					text:'发表意见',
					iconCls:'icon-add',
					handler:function(){
						WinOpen();
					}
				},'-',{
					text:'删除意见',
					iconCls:'icon-remove',
					handler:function(){
						remove();
					}
				},'-',{
					text:'查询',
					iconCls:'icon-search',
					handler:function(){
					    $('#opinionList').datagrid('options').url = 'opinionAction!getOpinionListJSON.action?startTime='+$('#d4311').val()+'&endTime='+$('#d4312').val()+'&manger='+$('#manger').val();
					    $('#opinionList').datagrid("reload");
					}
				}],
				 rownumbers:false,
				 frozenColumns:[[
				    {field:'ck',checkbox:true},
				    {title:'序号',field:'rownum',width:"35"}
				]],
				onLoadSuccess: function () {
				    $('.datagrid-toolbar').append($('#searchTable'));
				    $('#searchTable').show(); 		    
				}
			});
		});
		
		function getReversion(pid)
		{
			var winPar=window.showModalDialog("opinionAction!toGetReversionList.action?pid="+pid,'',"dialogWidth=600px;dialogHeight=800px;status:no;resizable=no;dialogLeft:400px;");
			 if(winPar == "refresh")  window.location.reload();
			
		}
	 
		function formatterAct(pid){
			return '<a href="#" onclick="getReversion('+pid+')"><img title="查看回复" src="${pageContext.request.contextPath }/images/kmag.png" border="0"></img></a>';
		} 
		
		function WinOpen(ids){
			   document.getElementById("opinionTitle").value="";
			   document.getElementById("opinionContext").value="";
			   $('#opinionWindows').window('open');
			   $('#opinionWindows').panel('setTitle',' 用户意见反馈');
		       $('#submitForm').show();
		}
	 
		function remove(){
			var selectedRows = $('#opinionList').datagrid('getSelections');
			var removeIds = '';
			if (selectedRows.length>0){
				for(var i=0; i<selectedRows.length; i++){
					if (removeIds != '') removeIds += ',';
					removeIds += selectedRows[i].Id;
				}
				$.messager.confirm('提示信息', '<div style="padding-top:15px;padding-left:5px"><b>确定删除？</b></div>', function(r){
					if (r){
						var url="opinionAction!toRemoveOpinion.action";
						$.post(
								url,
								{"removeIds":removeIds},
								function(data){
									eval('data='+data);
						        	var state = data.state;
						        	var retMsg = data.resultMsg;
						        	if(state==true){
						        		$('#opinionList').datagrid("reload");
						        	}
						        	$.messager.alert('提示信息','<div style="padding-top:15px;padding-left:5px"><b>'+retMsg+'</b></div>','info');
								}
						);
					}
				});

			}else{
		    	$.messager.alert('提示信息','<div style="padding-top:15px;padding-left:5px"><b>请至少选择一条数据！</b></div>','warning');
		    }
		}
	  
		function save(){
			//添加和修改保存
			$('#submitForm').form('submit',{
		        onSubmit: function(){     	
		        	return $('#submitForm').form('validate');
		        },
		        success:function(data){
		        	eval('data='+data);
		        	var state = data.state;
		        	var retMsg = data.resultMsg;
		        	$.messager.alert('提示信息','<div style="padding-top:15px;padding-left:5px"><b>'+retMsg+'</b></div>','info');
		        	if(state==true){
		    			$('#opinionList').datagrid('reload');
						$('#opinionWindows').window('close');
		        	}
		        }
			});
		} 
	</script>
</head>
<body class="easyui-layout">
  <div id="opinionWindows" class="easyui-window" closed="true"
		iconCls="icon-save" draggable="false" modal="true" resizable="false"
		maximizable="false" minimizable="false" title="发表意见"
		style="width: 600px; height: 290px; padding: 2px; background: #fafafa;">
		<div region="center" border="false"
			style="padding: 2px; background: #fff; border: 1px solid #ccc;">
			<%@include file="opinion.jsp"%>
		</div>
		<div region="south" border="false"
			style="text-align: right; height: 30px; line-height: 30px;">
			<a class="easyui-linkbutton" icon="icon-save"
				href="javascript:void(0)" onclick="save()">保存</a> <a
				class="easyui-linkbutton" icon="icon-back"
				href="javascript:void(0);"
				onclick="javascript:$('#opinionWindows').window('close');">返回</a>
		</div>
	</div>
	<input type="hidden" id="manger" name="manger" value="<%=username %>">
	<div region="center" title="我的留言" style="padding: 5px;" border="false">
		<table id="opinionList" fit="true" url="opinionAction!getOpinionListJSON.action?manger=<%=username %>">
			<thead>
				<tr>
				    <th field="opinionTitle" width="220">标题</th>
					<th field="opinionContext" width="350">意见内容</th>
					<th field="answerPerson" width="180">意见回复</th>
					<th field="opinionPerson" width="70">作者</th>
					<th field="opinionTime" width="132">发布时间</th>
					<th field="Id" formatter="formatterAct"
						align="center" width="40"> 操作</th>
				</tr>
			</thead>
		</table>
	</div>
  <table id="searchTable" style="display: none" border="0" cellpadding="0">
		<tr>
			<td width="25%">&nbsp;
			<b>时间范围:</b>
			<input type="text" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'d4312\')||\'2050-10-01\'}'})" id="d4311"   class="Wdate">
             到&nbsp;<input type="text" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'d4311\')}',maxDate:'2050-10-01'})" id="d4312"   class="Wdate">
             </td>
		<tr>
	</table>
</body>
</html>